<?php
global $_W, $_GPC;

$kwd = $_GPC['keyword'];
$pcate = intval($_GPC['pcate']);
//$sql = "SELECT * FROM " . tablename($this->table_goods) . " WHERE `weid`=:weid AND storeid=0 AND `title` LIKE :title AND `title`<>'' ORDER BY lasttime DESC,id DESC LIMIT 0,8";
$strwhere = "WHERE `weid`=" . $_W['uniacid'] ." AND storeid=0 AND `title`<>''";
if (!empty($kwd)) {
    $strwhere .= " AND `title` LIKE %{$kwd}% ";
}
if ($pcate != 0) {
    $strwhere .= " AND pcate={$pcate} ";
}

$sql = "SELECT * FROM " . tablename($this->table_goods) . " {$strwhere}  ORDER BY lasttime DESC,id DESC LIMIT 0,20";

$ds = pdo_fetchall($sql, $params);
foreach ($ds as &$row) {
    $r = array();
    $r['id'] = $row['id'];
    $r['title'] = str_replace('\'', '', $row['title']);
    $r['headimgurl'] = $row['thumb'];
    $row['entry'] = $r;

}
include $this->template('web/_query_goods');